<template>
  <view class="glo-tab" :class="{ active: active }" @click="handlerClick">
    <text class="name">{{ data.name }} </text>
    <view class="num" v-if="data.num">{{ data.num }}</view>
  </view>
</template>

<script setup>
const props = defineProps({
  data: {
    type: Object,
    default: () => { },
  },
  active: {
    type: Boolean,
    default: false,
  },
});

const emit = defineEmits(["change"]);

const handlerClick = () => {
  emit("change", props.data);
};
</script>

<style lang="scss" scoped>
.glo-tab {
  position: relative;

  .name {
    position: relative;
    z-index: 2;
    font-family: Alibaba PuHuiTi 2, Alibaba PuHuiTi 20;
    font-weight: 400;
    font-size: 26rpx;
    color: #767676;
    line-height: 30rpx;
  }

  .num {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    z-index: 3;
    top: -5rpx;
    right: -10rpx;
    width: 32rpx;
    height: 19rpx;
    background: #ff5050;
    border-radius: 10rpx 10rpx 10rpx 50rpx;
    font-size: 11rpx;
    color: #fff;
    text-align: center;
  }

  &.active {
    .name {
      font-size: 34rpx;
      color: #3d3d3d;
      line-height: 30rpx;
    }

    &::after {
      content: " ";
      position: absolute;
      z-index: 1;
      bottom: 0rpx;
      left: 0;
      width: 100%;
      height: 15rpx;
      border-radius: 4rpx;
      background: linear-gradient(90deg, #76ffdd 0%, #0fd6fe 50%, #3a82ff 100%);
    }
  }
}
</style>
